<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>GO机网管理后台</title>
	<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge">
	<link href="../../css/bootstrap.min.css" rel="stylesheet">
	<link href="css/nifty.min.css" rel="stylesheet">
	<link href="../../css/demo/nifty-demo-icons.min.css" rel="stylesheet">
	<link href="../../plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	<link href="../../css/user_defined.css" rel="stylesheet">
	<link href="../../plugins/pace/pace.min.css" rel="stylesheet">
	<script src="../../plugins/pace/pace.min.js?2016/8/5"></script>
	<script src="../../js/jquery-2.2.1.min.js"></script>
</head>

<!--TIPS-->
<!--You may remove all ID or Class names which contain "demo-", they are only used for demonstration. -->

<body id="main">
<div id="container" class="effect mainnav-lg">
	@@include('public/header.html')
	<div class="boxed">
		<div id="content-container">
			<div id="page-title">
				<h1 class="page-header text-overflow">城市开放设置</h1>
			</div>
			<!--===================================================-->
			<div id="page-content">
				<button class="btn btn-default" data-toggle="modal" data-target="#myModal">添加开放城市</button>
			</div>
			
			<div class="row mar-top pad-top pad-all">
				<style>
					table {
						color: #999;
						margin:auto;
					}
					td,th{
						padding: 5px;
						border:1px solid #bbbbbb;
					}
					th{
						text-align: center;
						background: #e6e6e6;
						font-size:25px;
					}
					td div{
						padding:5px 15px;
						margin:5px;
						font-size:16px;
						border:1px solid #ccc;
						display:inline-block;
					}
					select{
						padding:5px;
						margin-right:20px;
					}
				</style>
				<table>
					<tr>
						<th width="130">省份</th>
						<th width="450">城市</th>
					</tr>
					<tr v-for="c in partners">
						<td><div v-text="c.province"></div></td>
						<td><div v-for="t in c.city" v-text="t.city"></div></td>
					</tr>
				</table>
			</div>
			<!--===================================================-->
			<!--End page content-->
		</div>
		
		<nav id="mainnav-container">
			@@include('public/left_menu.html')
		</nav>
	
	</div>
	
	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<h4 class="modal-title" id="myModalLabel">开放城市</h4>
				</div>
				<div class="modal-body">
					<style>
						form{
							text-align: center;
						}
						form select{
							width:200px;
						}
						form div{margin-bottom:10px;}
					</style>
					<form class="form-horizontal">
						<div>
							<span>选择省份 : </span>
							<select v-model="province" v-on:change="loadCity()">
								<option v-for="p in provinces" v-bind:value="p" v-text="p.pr_province"></option>
							</select>
						</div>
						<div>
							<span>选择城市 : </span>
							<select v-model="city" >
								<option v-for="c in cities" v-bind:value="c" v-text="c.ci_city"></option>
							</select>
						</div>
						<div class="login-msg error" id="error1">
							<i class="fa fa-warning"></i>
							<p class="error"></p>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" id="addBrand" v-on:click="save()">确定添加</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div>
</div>
@@include('public/footer.html')
<script>
	var vue = new Vue({
		el: '#main',
		data: {
			partners:[],
			provinces:[],
			cities:[],
			province:{},
			city:{}
		},
		methods: {
			loadCity:function(){
				$.post(apiRecycle+"partner.php/Admin/City/get_city_lib", {
					pr_id:vue.province.pr_id
				}, function(res){
					vue.cities = res.data;
				}, "json");
			},
			save:function(){
				$.post(apiRecycle+"partner.php/Admin/City/set_city", {
					ci_city:vue.city.ci_city,
					pr_province:vue.province.pr_province
				}, function(res){
					if(res.code==200){
						location.reload();
					} else {
						alert(res.message);
					}
				}, "json");
			}
		},
		ready: function () {
			/*加载省份*/
			$.post(apiRecycle+"partner.php/Admin/City/get_province_lib", {}, function(res){
				vue.provinces = res.data;
			}, "json");
			
			/*获取城市列表*/
			$.post(apiRecycle+"partner.php/Admin/City/get_open_city", {}, function(res){
				vue.partners = res.data;
			}, "json")
		}
	});
</script>
</body>
</html>
